class Admin::FeedbacksController < AdminController
  def index
    @feedbacks = Feedback.order("created_at DESC").page(params[:page]).per(params[:per])
  end

  def edit
    @feedback = Feedback.find params[:id]
  end

  def update
    @feedback = Feedback.find params[:id]
    @feedback.admin_id = current_admin.id
    if @feedback.update feedback_params
      redirect_to admin_feedbacks_path, notice: "处理成功."
    else
      redirect_to admin_feedbacks_path, notice: "处理失败."
    end
  end

  def destroy
    @feedback = Feedback.find params[:id]
    if @feedback.destroy
      redirect_to admin_feedbacks_path, notice: "删除成功."
    else
      redirect_to admin_feedbacks_path, notice: "删除失败."
    end
  end

  private

  def feedback_params
    params.require(:feedback).permit(:content, :reply)
  end
end
